<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./template.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">
        <h:outputStylesheet library="css" name="acesso.css" />
        <h:outputScript library="script" name="script.js"/>
        <h:form id="frmAcesso">
            <p:messages />
            <p:panel header="Cadastro de Acesso">
                <h:panelGrid columns="2">
                    <h:outputLabel />
                    <h:inputHidden value="#{bAcesso.acesso.id}" />
                    <h:outputLabel value="Nome.:" styleClass="lbt"/>
                    <p:inputText value="#{bAcesso.acesso.nome}" styleClass="texto" onkeyup="this.value = this.value.toUpperCase()" required="true" requiredMessage="Campo nome não pode ser vazio" />
                    <h:outputLabel value="Login.:" styleClass="lbt" />
                    <p:inputText value="#{bAcesso.acesso.login}" styleClass="texto" onkeyup="this.value = this.value.toUpperCase()" required="true" requiredMessage="Campo login não pode ser vazio" />
                    <h:outputLabel value="Senha.:" styleClass="lbt" />
                    <p:password id="senha" value="#{bAcesso.acesso.senha}" match="conf" label="senha" requiredMessage="Senha não confere" styleClass="texto" onkeyup="this.value = this.value.toUpperCase()" />
                    <h:outputLabel value="Confirmar.:" styleClass="lbt" />
                    <p:password id="conf" styleClass="texto" onkeyup="this.value = this.value.toUpperCase()" />
                </h:panelGrid>
                <h:commandButton value="Salvar" action="#{bAcesso.gravar}">
                    <p:ajax  event="keyup" update="@form"/>
                </h:commandButton>
                <h:commandButton value="Limpar" action="#{bAcesso.limpar}">
                    <p:ajax  event="keyup" update="@form"/>
                </h:commandButton>
            </p:panel>
        </h:form>
        <h:form id="frmTable">
            <p:dataTable value="#{bAcesso.acessos}" var="a">
                <p:column headerText="Codigo" width="50">
                    <h:outputText value="#{a.id}" />
                </p:column>
                <p:column headerText="Nome" width="150">
                    <h:outputText value="#{a.nome}" />
                </p:column>
                <p:column headerText="Login" width="100">
                    <h:outputText value="#{a.login}" />
                </p:column>
                <p:column headerText="Senha" width="100">
                    <h:outputText value="#{a.senha}" />
                </p:column>
                <p:column headerText="Op" width="70" style="text-align: center">
                    <h:commandLink value="Alterar" action="#{bAcesso.alterar(a.id)}" /> |
                    <h:commandLink value="Excluir" action="#{bAcesso.excluir(a.id)}" onclick="return confirmaExclusao();"/>   
                </p:column>
            </p:dataTable>

        </h:form>
    </ui:define>    

</ui:composition>
